<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "customer_service_messages".
 *
 * @property int $id
 * @property int $from_user_id 发送方id
 * @property int $to_user_id 接收方id
 * @property string $content 内容
 * @property string $alt_image 附加：图片url
 * @property string $alt_image1 附加：图片url
 * @property string $alt_image2 附加：图片url
 * @property int|null $status 状态
 * @property string $ctime 创建时间
 * @property string $utime 更新时间
 */
class CustomerServiceMessages extends BaseModel {
    /**
     * {@inheritdoc}
     */
    public static function tableName() {
        return 'customer_service_messages';
    }

    /**
     * {@inheritdoc}
     */
    public function rules() {
        return [
            [['from_user_id', 'to_user_id'], 'required'],
            [['from_user_id', 'to_user_id', 'status'], 'integer'],
            [['ctime', 'utime'], 'safe'],
            [['content'], 'string', 'max' => 256],
            [['alt_image','alt_image1','alt_image2'], 'string', 'max' => 128],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels() {
        return [
            'id' => 'ID',
            'from_user_id' => 'From User ID',
            'to_user_id' => 'To User ID',
            'content' => 'Content',
            'alt_image' => 'Alt Image',
            'alt_image1' => 'Alt Image1',
            'alt_image2' => 'Alt Image2',
            'status' => 'Status',
            'ctime' => 'Ctime',
            'utime' => 'Utime',
        ];
    }

    public function getFormUsers() {
        return $this->hasOne(Users::class, ['id' => 'from_user_id']);
    }

    public function getToUsers() {
        return $this->hasOne(Users::class, ['id' => 'to_user_id']);
    }
}
